home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 March / PCWorld_2008-03_cd.bin / Audio-video / mediamonkey / MediaMonkey_3.0.2.1134.exe / {app} / Scripts / Stats.vbs < prev    next >
Text File  |  2007-12-21  |  67KB  |  1,316 lines

  1. ' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  2. ' This file can be replaced  in one of the future versions,
  3. ' so please if you want to modify it, make  a copy, do your
  4. ' modifications  in that copy and  change Scripts.ini  file 
  5. ' appropriately. 
  6. ' If you do not do this, you will lose  all your changes in
  7. ' this script when you install a new version of MediaMonkey
  8. ' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  9.  
  10. ' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  11. ' MediaMonkey statistics script
  12. ' This script was adapted by TheRocket from the 
  13. ' MediaMonkey Web Extension (MMWBE) also made by myself.
  14. ' Coded in December 2004 - January 2005.
  15. ' Thanks to Rusty for his suggestions and letting me
  16. ' include this script into the next versions!
  17. ' It shows globaly the songs you have in your MediaMonkey,
  18. ' and what you listen often. It can be a great way to
  19. ' find what type of music a person likes.
  20. ' Send us new statistics ideas in the MediaMonkey Forum!
  21. ' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  22.  
  23. Option Explicit
  24.  
  25. Public booStyleOn
  26.  
  27. Const intTopCount = 10
  28. Const mmAnchorRight = 4
  29. Const mmAnchorBottom = 8
  30. Const mmAlignTop = 1
  31. Const mmAlignBottom = 2
  32. Const mmAlignClient = 5
  33. Const mmListDropdown = 2
  34. Const mmFormScreenCenter = 4
  35.  
  36. 'Set English - United States system locale.
  37. SetLocale("en-us")
  38.  
  39. Sub ShowStats()
  40. Dim UI
  41. Dim Form
  42. Dim Foot
  43. Dim Btn
  44. Dim Btn2
  45. Dim WB
  46. Dim doc
  47. Dim DlgWidth
  48.  
  49.   Set UI = SDB.UI
  50.  
  51.   DlgWidth = 500
  52.  
  53.   ' Create the window to be shown
  54.   Set Form = UI.NewForm
  55.   Form.Common.SetRect 50, 50, DlgWidth, 400
  56.   Form.Common.MinWidth = 200
  57.   Form.Common.MinHeight = 150
  58.   Form.FormPosition = mmFormScreenCenter
  59.   Form.Caption = SDB.Localize("MediaMonkey Music Library Statistics")
  60.   Form.StayOnTop = True
  61.  
  62.   ' Create a panel at the bottom of the window
  63.   Set Foot = UI.NewPanel(Form)
  64.   Foot.Common.Align = mmAlignBottom
  65.   Foot.Common.Height = 35
  66.  
  67.   ' Create a button that saves the report
  68.   Set Btn2 = UI.NewButton(Foot)
  69.   Btn2.Caption = SDB.Localize("&Save as...")
  70.   Btn2.Common.SetRect DlgWidth - 261, 5, 150, 25
  71.   'Btn2.Common.Hint = SDB.Localize("Save this report")
  72.   Btn2.Common.Anchors = mmAnchorRight + mmAnchorBottom
  73.   Btn2.UseScript = Script.ScriptPath
  74.   Btn2.OnClickFunc = "SaveAs"
  75.  
  76.   ' Create a button that closes the window
  77.   Set Btn = UI.NewButton(Foot)
  78.   Btn.Caption = SDB.Localize("&Close")
  79.   Btn.Common.SetRect DlgWidth - 106, 5, 85, 25
  80.   'Btn.Common.Hint = SDB.Localize("Close this report")
  81.   Btn.Common.Anchors = mmAnchorRight + mmAnchorBottom
  82.   Btn.Cancel = True
  83.   Btn.UseScript = Script.ScriptPath
  84.   Btn.OnClickFunc = "OnClose"
  85.    
  86.   ' Create a web browser component
  87.   Set WB = UI.NewActiveX(Form, "Shell.Explorer")
  88.  
  89.   ' process background threads
  90.   SDB.ProcessMessages
  91.  
  92.   WB.Common.Align = mmAlignClient      ' Fill all client rectangle
  93.   WB.Common.ControlName = "WB"
  94.  
  95.   Form.SavePositionName = "StatisticsWindow"
  96.   Form.Common.Visible = True                ' Only show the form, don't wait for user input
  97.   SDB.Objects("Statistics") = Form  ' Save reference to the form somewhere, otherwise it would simply disappear
  98.   WB.SetHTMLDocument( BuildReport(false))
  99.  
  100.   ' process background threads
  101.   SDB.ProcessMessages
  102.  
  103. End Sub
  104.  
  105. Sub OnClose(Btn)
  106.   SDB.Objects("Statistics") = Nothing ' Remove the last reference to our form which also causes it to disappear
  107. End Sub
  108.  
  109. Function Style()
  110.   booStyleOn = Not booStyleOn
  111.   If booStyleOn Then
  112.     Style = ""
  113.   Else
  114.     Style = " class=""Dark"""
  115.   End If
  116. End Function
  117.  
  118. Public Function FormatFileSize(intFileLength)
  119. Dim strSize
  120.     strSize = SDB.Localize("Bytes")
  121.     If intFileLength >= 1024 Then
  122.       intFileLength = Round(intFileLength / 1024)
  123.       strSize = SDB.Localize("KB")
  124.     End If
  125.     If intFileLength >= 1024 Then
  126.       intFileLength = Round(intFileLength / 1024, 2)
  127.       strSize = SDB.Localize("MB")
  128.     End If
  129.     If intFileLength >= 1024 Then
  130.       intFileLength = Round(intFileLength / 1024, 2)
  131.       strSize = SDB.Localize("GB")
  132.     End If
  133.     If intFileLength >= 1024 Then
  134.       intFileLength = Round(intFileLength / 1024, 2)
  135.       strSize = SDB.Localize("TB")
  136.     End If
  137.     FormatFileSize = intFileLength & " " & strSize
  138. End Function
  139.  
  140. Public Function FormatTime(intLength)
  141.   Dim strLength, intLengthHeures, intLengthMinutes, intLengthSecondes, datLength
  142.   Dim strTimeSeparator
  143.   'Find out the current time separator (for some locales, it is a period)
  144.   datLength = TimeSerial(11, 11, 11)
  145.   strLength = FormatDateTime(datLength,vbshorttime)
  146.   strTimeSeparator = left(replace(strLength,"1",""),1)
  147.  
  148.   intLength = CCur(intLength / 1000)
  149.   intLengthHeures = Int((intLength / 60) / 60)
  150.   intLengthMinutes = Int((intLength / 60) Mod 60)
  151.   intLengthSecondes = Int(intLength Mod 60)
  152.  
  153.   strLength = intLengthHeures & strTimeSeparator
  154.   if intLengthMinutes < 10 then strLength = strLength & "0"
  155.   strLength = strLength & intLengthMinutes & strTimeSeparator
  156.  
  157.   if intLengthSecondes < 10 then strLength = strLength & "0"
  158.   strLength = strLength & intLengthSecondes
  159.  
  160.   FormatTime = strLength
  161. End Function
  162.  
  163.  ' escape XML string
  164. Function MapXML(srcstring)
  165.   srcstring = Replace(srcstring, "&", "&")
  166.   srcstring = Replace(srcstring, "<", "<")
  167.   srcstring = Replace(srcstring, ">", ">")
  168.   Dim i
  169.   i=1
  170.   While i<=Len(srcstring)
  171.     ' process background threads
  172.     SDB.ProcessMessages
  173.  
  174.     If (AscW(Mid(srcstring, i, 1))>127) Then
  175.       srcstring = Mid( srcstring, 1, i-1)+"&#"+CStr( AscW( Mid( srcstring, i, 1)))+";"+Mid( srcstring, i+1, Len(srcstring))
  176.     End If
  177.     i=i+1
  178.   WEnd
  179.   If srcstring="" Then
  180.     srcstring = " "
  181.   End IF
  182.   MapXML = srcstring
  183. End Function
  184.  
  185.  
  186. Function ExtractText(ByVal inText, ByVal inDebut, ByVal inFin)
  187.     Dim pos1
  188.     Dim pos2
  189.  
  190.     pos1 = InStr(1, inText, inDebut)
  191.     If pos1 = 0 Then pos1 = 1 Else pos1 = pos1 + Len(inDebut)
  192.     pos2 = InStr(pos1, inText, inFin)
  193.     If pos2 < pos1 Then pos2 = Len(inText) + 1
  194.     ExtractText = Mid(inText, pos1, pos2 - pos1)
  195.     
  196. End Function
  197.  
  198. Function ExtractTextInvert(ByVal inText, ByVal inDebut, ByVal inFin)
  199.     ExtractTextInvert = StrReverse(ExtractText(StrReverse(inText), StrReverse(inDebut), StrReverse(inFin)))
  200. End Function
  201.  
  202. function ExtractPathName(strPath)
  203.   dim StrTemp
  204.   StrTemp= ExtractTextInvert(strPath,"","\")
  205.   ExtractPathName = Left(strPath, Len(strPath) - Len(StrTemp))
  206. end function
  207.  
  208. Function ShowRating(intNo, booForExport)
  209. Dim a
  210.   If intNo = -1 Then
  211.     ShowRating = " "
  212.   ElseIf intNo = 0 Then
  213.     if not booForExport then
  214.       ShowRating = "<img src=""" & ExtractPathName(script.scriptpath) & "\bomb.png"" border=""0"" width=""10"" height=""11"">"
  215.     else
  216.       ShowRating = "0"
  217.     end if
  218.   Else
  219. '    ShowRating = round(intNo / 10) / 2
  220.     For a = 20 To intNo Step 20
  221.       ' process background threads
  222.       SDB.ProcessMessages
  223.       if not booForExport then
  224.         ShowRating = ShowRating & "<img src=""" & ExtractPathName(script.scriptpath) & "\star.png"" width=""10"" height=""11"" border=""0"">"
  225.       else
  226.         ShowRating = ShowRating & "*"
  227.       end if
  228.     Next
  229.   End If
  230.   If (intNo Mod 20) >= 10 Then
  231.     if not booForExport then
  232.       ShowRating = ShowRating & "<img src=""" & ExtractPathName(script.scriptpath) & "\half-star.png"" width=""10"" height=""11"" border=""0"">"
  233.     else
  234.       ShowRating = ShowRating & """
  235.     end if
  236.   End If
  237. End Function
  238.  
  239. function NoNull(VarCanBeNull, varWhenNull)
  240.   if IsNull (VarCanBeNull) Then
  241.     NoNull = varWhenNull
  242.   else
  243.     if IsNumeric (VarCanBeNull) Then
  244.       NoNull = VarCanBeNull
  245.     else
  246.       if VarType (VarCanBeNull) = vbString Then
  247.         if Len (VarCanBeNull) > 0 Then
  248.           NoNull = VarCanBeNull
  249.         else
  250.           NoNull = varWhenNull
  251.         end if
  252.       else
  253.         NoNull = varWhenNull
  254.       end if
  255.     end if
  256.   end if
  257. end function
  258.  
  259. Sub SaveAS(Btn)
  260.   Dim strExportTo
  261.   Dim booSave
  262.   Dim fout 
  263.   Dim fso
  264.  
  265.   With SDB.CommonDialog
  266.     .DefaultExt = "html"
  267.     '.FileName = SDB.Localize("Save AS...")
  268.     .Filter = "HTML (*.htm)|*.htm|All files (*.*)|*.*"
  269.     .Title = SDB.Localize("Exporting...")
  270.     .InitDir = SDB.IniFile.StringValue("Scripts", "LastExportStatsDir")
  271.     .ShowSave
  272.     booSave = .Ok
  273.     strExportTo = .FileName
  274.   End With
  275.  
  276.   if booSave then
  277.     ' Connect to the FileSystemObject
  278.     Set fso = SDB.Tools.FileSystem
  279.  
  280.     ' Create the output file 
  281.     Set fout = fso.CreateTextFile(strExportTo, True) 
  282.  
  283.     ' Write header line 
  284.     fout.Write BuildReport(true) 
  285.     ' Close the output file and finish 
  286.     fout.Close 
  287.     
  288.     set fout = nothing
  289.     set fso = nothing
  290.  
  291.   end if
  292.  
  293. end sub
  294.  
  295. Function BuildReport(booForExport)
  296.   Dim qryStats 
  297.   Dim strSQL
  298.   Dim intArtistsCount
  299.   Dim intArtistsCountPlayed
  300.   Dim intAlbumCount
  301.   Dim intAlbumsCountPlayed
  302.   Dim intGenreCount
  303.   Dim intGenreCountPlayed
  304.   Dim intLength
  305.   Dim intFileLength
  306.   Dim intLengthPlayed
  307.   Dim intFileLengthPlayed
  308.   Dim intYearCount
  309.   Dim intYearCountPlayed
  310.   Dim intPlaylistCount
  311.   Dim intPlaylistCountPlayed
  312.   Dim intPlayed
  313.   Dim intAllCount
  314.  
  315.   Dim strOut
  316.  
  317.   strOut = ""
  318.     
  319.   'Building base page
  320.   strOut = strOut & "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">" & vbcrlf
  321.   strOut = strOut & "<html>" & vbcrlf
  322.   strOut = strOut & "  <head>" & vbcrlf
  323.   strOut = strOut & "    <title>" & SDB.Localize("MediaMonkey Music Library Statistics") & "</title>" & vbcrlf
  324.   strOut = strOut & "  </head>" & vbcrlf
  325.  
  326.   strOut = strOut & "<STYLE TYPE=text/css>" & vbcrlf
  327.   strOut = strOut & "body{font-family:'Verdana',sans-serif; background-color:#FFFFFF; font-size:9pt; color:#000000;}" & vbcrlf
  328.   strOut = strOut & "H1{font-family:'Verdana',sans-serif; font-size:13pt; font-weight:bold; color:#AAAAAA; text-align:left}" & vbcrlf
  329.   strOut = strOut & "P{font-family:'Verdana',sans-serif; font-size:9pt; color:#000000;}" & vbcrlf
  330.   strOut = strOut & "TH{font-family:'Verdana',sans-serif; font-size:10pt; font-weight:bold; color:#000000; border-color:#000000; border-style: solid; border-left-width:0px; border-right-width:0px; border-top-width:0px; border-bottom-width:3px;}" & vbcrlf
  331.   strOut = strOut & "TD{font-family:'Verdana',sans-serif; font-size:9pt; color:#000000; border-color:#000000; border-style: solid; border-left-width:0px; border-right-width:0px; border-top-width:0px; border-bottom-width:1px;}" & vbcrlf
  332.   strOut = strOut & "TR.dark{background-color:#EEEEEE}" & vbcrlf
  333.   strOut = strOut & "TR.aleft TH{text-align:left}" & vbcrlf
  334.   strOut = strOut & "</STYLE>" & vbcrlf
  335.  
  336.   strOut = strOut & "  <body>" & vbcrlf
  337.   strOut = strOut & "    <H1>" & SDB.Localize("MediaMonkey Music Library Statistics") & "</H1>" & vbcrlf
  338.   
  339.   ' process background threads
  340.   SDB.ProcessMessages
  341.   
  342.   'Totals
  343.   strSQL = "SELECT Count(*) AS Nombre FROM Artists WHERE ID <> 0 AND Tracks>0"     ' Track artists only
  344.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  345.   intArtistsCount = CLng(NoNull(qryStats.ValueByName("Nombre"),0))
  346.   
  347.   ' process background threads
  348.   SDB.ProcessMessages
  349.  
  350.   strSQL = "SELECT Count(Distinct Artists.ID) AS CountOfID FROM Artists INNER JOIN ArtistsSongs ON Artists.ID = ArtistsSongs.IDArtist INNER JOIN Played ON ArtistsSongs.IDSong = Played.IDSong"
  351.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  352.   intArtistsCountPlayed = CLng(NoNull(qryStats.ValueByName("CountOfID"),0))
  353.   
  354.   ' process background threads
  355.   SDB.ProcessMessages
  356.  
  357.   strSQL = "SELECT Count(*) AS Nombre FROM Albums WHERE Album<>'' AND Album<>' '"
  358.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  359.   intAlbumCount = CLng(NoNull(qryStats.ValueByName("Nombre"),0))
  360.   
  361.   ' process background threads
  362.   SDB.ProcessMessages
  363.  
  364.   strSQL = "SELECT Count(Distinct Albums.ID) AS CountOfID FROM Albums INNER JOIN Songs ON Albums.ID = Songs.IDAlbum INNER JOIN Played ON Played.IDSong = Songs.ID"
  365.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  366.   intAlbumsCountPlayed = CLng(NoNull(qryStats.ValueByName("CountOfID"),0))
  367.   
  368.   ' process background threads
  369.   SDB.ProcessMessages
  370.  
  371.   strSQL = "SELECT Count(Distinct Genres.IDGenre) AS Nombre FROM Genres INNER JOIN GenresSongs ON Genres.IDGenre = GenresSongs.IDGenre INNER JOIN Songs ON Songs.ID = GenresSongs.IDSong"
  372.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  373.   intGenreCount = CLng(NoNull(qryStats.ValueByName("Nombre"),0))
  374.   
  375.   ' process background threads
  376.   SDB.ProcessMessages
  377.  
  378.   strSQL = "SELECT Count(Distinct Genres.IDGenre) AS CountOfID FROM Genres INNER JOIN GenresSongs ON Genres.IDGenre = GenresSongs.IDGenre INNER JOIN Songs ON Songs.ID = GenresSongs.IDSong INNER JOIN Played ON Songs.ID = Played.IDSong"
  379.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  380.   intGenreCountPlayed = CLng(NoNull(qryStats.ValueByName("CountOfID"),0))
  381.  
  382.   ' process background threads
  383.   SDB.ProcessMessages
  384.  
  385.   strSQL = "SELECT Count(Distinct CAST((Songs.Year/10000) AS INTEGER)) AS Nombre FROM Songs WHERE Songs.Year > 0"
  386.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  387.   intYearCount = CLng(NoNull(qryStats.ValueByName("Nombre"),0))
  388.  
  389.   ' process background threads
  390.   SDB.ProcessMessages
  391.  
  392.   strSQL = "SELECT Count(Distinct CAST((Songs.Year/10000) AS INTEGER)) AS CountOfID FROM Songs INNER JOIN Played ON Songs.ID = Played.IDSong WHERE Songs.Year > 0"
  393.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  394.   intYearCountPlayed = CLng(NoNull(qryStats.ValueByName("CountOfID"),0))
  395.  
  396.   ' process background threads
  397.   SDB.ProcessMessages
  398.  
  399.   strSQL = "SELECT Count(*) AS Nombre FROM PlayLists WHERE (ISAutoPlayList ISNULL or IsAutoPlaylist=0)"
  400.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  401.   intPlaylistCount = CLng(NoNull(qryStats.ValueByName("Nombre"),0))
  402.  
  403.   ' process background threads
  404.   SDB.ProcessMessages
  405.  
  406.   strSQL = "SELECT Count(Distinct PlayLists.IDPlaylist) AS CountOfID FROM "
  407.   strSQL = strSQL & "PlayLists INNER JOIN PlaylistSongs ON PlayLists.IDPlaylist = PlaylistSongs.IDPlaylist "
  408.   strSQL = strSQL & "INNER JOIN Songs ON PlaylistSongs.IDSong = Songs.ID INNER JOIN Played ON Songs.ID = Played.IDSong "
  409.   strSQL = strSQL & "WHERE (PlayLists.ISAutoPlayList ISNULL or Playlists.IsAutoPlaylist=0)"
  410.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  411.   intPlaylistCountPlayed = CLng(NoNull(qryStats.ValueByName("CountOfID"),0))
  412.  
  413.   ' process background threads
  414.   SDB.ProcessMessages
  415.  
  416.   strSQL = "SELECT Count(Distinct Songs.ID) AS Nombre FROM Songs INNER JOIN Played ON Songs.ID = Played.IDSong"
  417.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  418.   intPlayed = CLng(NoNull(qryStats.ValueByName("Nombre"),0))
  419.  
  420.   ' process background threads
  421.   SDB.ProcessMessages
  422.  
  423.   strSQL = "SELECT Count(*) AS Nombre, Sum(Songs.SongLength) AS TotalLength, Sum(Songs.FileLength) AS TotalFileLength FROM Songs"
  424.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  425.   intAllCount = CLng(NoNull(qryStats.StringByName("Nombre"),0))
  426.   intLength = CCur(NoNull(qryStats.ValueByName("TotalLength"),0))
  427.   intFileLength = CCur(NoNull(qryStats.ValueByName("TotalFileLength"),0))
  428.  
  429.   ' process background threads
  430.   SDB.ProcessMessages
  431.  
  432.   strSQL = "SELECT Sum(Songs.SongLength) AS TotalLength, Sum(Songs.FileLength) AS TotalFileLength FROM Songs INNER JOIN Played ON Songs.ID = Played.IdSong"
  433.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  434.   intLengthPlayed = CCur(NoNull(qryStats.ValueByName("TotalLength"),0))
  435.   intFileLengthPlayed = CCur(NoNull(qryStats.ValueByName("TotalFileLength"),0))
  436.  
  437.   ' process background threads
  438.   SDB.ProcessMessages
  439.  
  440.   strOut = strOut & "      <p/>" & vbcrlf
  441.   strOut = strOut & "        <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf
  442.   strOut = strOut & "          <tr><th colspan=""3"">" & SDB.Localize("Totals") & "</th></tr>" & vbcrlf
  443.   strOut = strOut & "          <tr class=""aleft""><th>" & SDB.Localize("Type") & "</th><th>" & SDB.Localize("Library") & "</th><th>" & SDB.Localize("Played") & "</th></tr>" & vbcrlf
  444.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Artists") & "</td><td>" & intArtistsCount & "</td><td>" & intArtistsCountPlayed & "</td></tr>" & vbcrlf
  445.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Albums") & "</td><td>" & intAlbumCount & "</td><td>" & intAlbumsCountPlayed & "</td></tr>" & vbcrlf
  446.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Genres") & "</td><td>" & intGenreCount & "</td><td>" & intGenreCountPlayed & "</td></tr>" & vbcrlf
  447.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Years") & "</td><td>" & intYearCount & "</td><td>" & intYearCountPlayed & "</td></tr>" & vbcrlf
  448.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Playlists") & "</td><td>" & intPlaylistCount & "</td><td>" & intPlaylistCountPlayed & "</td></tr>" & vbcrlf
  449.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Tracks") & "</td><td>" & intAllCount & "</td><td>" & intPlayed & "</td></tr>" & vbcrlf
  450.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Length") & " (h:mm:ss)</td><td>" & FormatTime(intLength) & "</td><td>" & FormatTime(intLengthPlayed) & "</td></tr>" & vbcrlf
  451.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("File size") & "</td><td>" & FormatFileSize(intFileLength) & "</td><td>" & FormatFileSize(intFileLengthPlayed) & "</td></tr>" & vbcrlf
  452.   'strOut = strOut & "          <tr><td colspan=""3"">* = " & SDB.Localize("Parts of item played") & "</td></tr>" & vbcrlf
  453.   strOut = strOut & "        </table>" & vbcrlf
  454.   strOut = strOut & "      <p/>" & vbcrlf
  455.   
  456.   ' process background threads
  457.   SDB.ProcessMessages
  458.  
  459.   'Averages
  460.   Dim intAvgYear
  461.   Dim intAvgYearPlayed
  462.   Dim intAvgBitrate
  463.   Dim intAvgBitratePlayed
  464.   Dim intAvgRating
  465.   Dim intTracksPerAlbum
  466.   Dim intTracksPerAlbumPlayed
  467.   Dim intSongsPerGenre
  468.   Dim intSongsPerGenrePlayed
  469.   Dim intPlayPerDay
  470.   Dim intPlayedRating
  471.   Dim intSongsPerArtist
  472.   Dim intSongsPerArtistPlayed
  473.   Dim intSongsPerYear
  474.   Dim intSongsPerYearPlayed
  475.   'Dim intSongsPerRating
  476.   'Dim intSongsPerRatingPlayed
  477.  
  478.   strSQL = "SELECT Avg(Distinct CAST((Songs.Year/10000) AS INTEGER)) AS avgYear FROM Songs WHERE Songs.Year > 0"
  479.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  480.   intAvgYear = CCur(NoNull(qryStats.ValueByName("avgYear"),0))
  481.  
  482.   ' process background threads
  483.   SDB.ProcessMessages
  484.  
  485.   strSQL = "SELECT Avg(Distinct Cast((Songs.Year/10000) AS Integer)) AS avgYearPlayed FROM Songs INNER JOIN Played ON Songs.ID = Played.IDSong WHERE Songs.Year > 0"
  486.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  487.   intAvgYearPlayed = CCur(NoNull(qryStats.ValueByName("avgYearPlayed"),0))
  488.  
  489.   ' process background threads
  490.   SDB.ProcessMessages
  491.  
  492.   strSQL = "SELECT Avg(SongLength) AS AvgLength, Avg(FileLength) AS AvgFileLength, Avg(Bitrate) AS AvgBitrate FROM Songs"
  493.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  494.   intLength = CCur(NoNull(qryStats.ValueByName("AvgLength"),0))
  495.   intFileLength = CCur(NoNull(qryStats.ValueByName("AvgFileLength"),0))
  496.   intAvgBitrate = CCur(NoNull(qryStats.ValueByName("AvgBitrate"),0))
  497.  
  498.   ' process background threads
  499.   SDB.ProcessMessages
  500.  
  501.   strSQL = "SELECT Avg(Songs.Bitrate) AS AvgBitratePlayed FROM Songs INNER JOIN Played ON Songs.ID = Played.IDSong"
  502.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  503.   intAvgBitratePlayed = CCur(NoNull(qryStats.ValueByName("AvgBitratePlayed"),0))
  504.  
  505.   ' process background threads
  506.   SDB.ProcessMessages
  507.  
  508.   strSQL = "SELECT Avg(Songs.Rating) AS AvgRating FROM Songs WHERE Songs.Rating >= 0"
  509.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  510.   intAvgRating = CCur(NoNull(qryStats.ValueByName("AvgRating"),0))
  511.  
  512.   ' process background threads
  513.   SDB.ProcessMessages
  514.  
  515.   strSQL = "SELECT Avg(SongLength) AS AvgLength, Avg(FileLength) AS AvgFileLength FROM Songs INNER JOIN Played ON Songs.ID = Played.IdSong"
  516.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  517.   intLengthPlayed = CCur(NoNull(qryStats.ValueByName("AvgLength"),0))
  518.   intFileLengthPlayed = CCur(NoNull(qryStats.ValueByName("AvgFileLength"),0))
  519.   
  520.   ' process background threads
  521.   SDB.ProcessMessages
  522.  
  523.   strSQL = "SELECT Avg(CountOfID) AS AVGTracks FROM ("
  524.   strSQL = strSQL & "SELECT Count(ArtistsAlbums.ID) AS CountOfID "
  525.   strSQL = strSQL & "FROM ArtistsAlbums INNER JOIN Songs ON ArtistsAlbums.IDAlbum = Songs.IDAlbum "
  526.   strSQL = strSQL & "WHERE (Songs.Album <> '') AND (Songs.Album NOTNULL) "
  527.   strSQL = strSQL & "GROUP BY ArtistsAlbums.IDAlbum)"
  528.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  529.   intTracksPerAlbum = CCur(NoNull(qryStats.ValueByName("AVGTracks"),0))
  530.  
  531.   ' process background threads
  532.   SDB.ProcessMessages
  533.  
  534.   strSQL = "SELECT Avg(CountOfID) AS AVGTracksPlayed FROM ("
  535.   strSQL = strSQL & "SELECT Count(ArtistsAlbums.ID) AS CountOfID "
  536.   strSQL = strSQL & "FROM ArtistsAlbums INNER JOIN Songs ON ArtistsAlbums.IDAlbum = Songs.IDAlbum "
  537.   strSQL = strSQL & "INNER JOIN Played ON Songs.ID = Played.IDSong "
  538.   strSQL = strSQL & "WHERE (Songs.Album <> '') AND (Songs.Album NOTNULL) "
  539.   strSQL = strSQL & "GROUP BY ArtistsAlbums.IDAlbum)"
  540.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  541.   intTracksPerAlbumPlayed = CCur(NoNull(qryStats.ValueByName("AVGTracksPlayed"),0))
  542.  
  543.   ' process background threads
  544.   SDB.ProcessMessages
  545.  
  546.   strSQL = "SELECT Avg(CountOfID) AS AVGPlayed FROM (SELECT Count(Songs.ID) AS CountOfID " 
  547.   strSQL = strSQL & "FROM Songs INNER JOIN Played ON Songs.ID = Played.IdSong "
  548.   strSQL = strSQL & "GROUP BY Cast(Played.PlayDate AS Integer))"
  549.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  550.   intPlayPerDay = CCur(NoNull(qryStats.ValueByName("AVGPlayed"),0))
  551.  
  552.   ' process background threads
  553.   SDB.ProcessMessages
  554.  
  555.   strSQL = "SELECT Avg(Songs.Rating) AS AvgRatingPlayed FROM Songs WHERE Songs.Rating>0 AND PlayCounter>0"
  556.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  557.   intPlayedRating = CCur(NoNull(qryStats.ValueByName("AvgRatingPlayed"),0))
  558.  
  559.   ' process background threads
  560.   SDB.ProcessMessages
  561.  
  562.   strSQL = "SELECT Avg(CountOfID) AS AVGGenre FROM ("
  563.   strSQL = strSQL & "SELECT Count(GenresSongs.ID) AS CountOfID "
  564.   strSQL = strSQL & "FROM GenresSongs INNER JOIN Songs ON GenresSongs.IDSong = Songs.ID "
  565.   strSQL = strSQL & "WHERE (Songs.Genre <> '') AND (Songs.Genre NOTNULL) "
  566.   strSQL = strSQL & "GROUP BY GenresSongs.IDGenre)"
  567.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  568.   intSongsPerGenre = CCur(NoNull(qryStats.ValueByName("AVGGenre"),0))
  569.  
  570.   ' process background threads
  571.   SDB.ProcessMessages
  572.  
  573.   strSQL = "SELECT Avg(CountOfID) AS AVGGenrePlayed FROM ("
  574.   strSQL = strSQL & "SELECT Count(GenresSongs.ID) AS CountOfID "
  575.   strSQL = strSQL & "FROM GenresSongs INNER JOIN Songs ON GenresSongs.IDSong = Songs.ID "
  576.   strSQL = strSQL & "INNER JOIN Played ON Songs.ID = Played.IDSong "
  577.   strSQL = strSQL & "WHERE (Songs.Genre <> '') AND (Songs.Genre NOTNULL) "
  578.   strSQL = strSQL & "GROUP BY GenresSongs.IDGenre)"
  579.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  580.   intSongsPerGenrePlayed = CCur(NoNull(qryStats.ValueByName("AVGGenrePlayed"),0))
  581.  
  582.   ' process background threads
  583.   SDB.ProcessMessages
  584.  
  585.   strSQL = "SELECT Avg(CountOfID) AS AVGArtist FROM ("
  586.   strSQL = strSQL & "SELECT Count(ArtistsSongs.ID) AS CountOfID "
  587.   strSQL = strSQL & "FROM ArtistsSongs INNER JOIN Songs ON ArtistsSongs.IDSong = Songs.ID "
  588.   strSQL = strSQL & "WHERE (Songs.Artist <> '') AND (Songs.Artist NOTNULL) "
  589.   strSQL = strSQL & "GROUP BY ArtistsSongs.IDArtist)"
  590.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  591.   intSongsPerArtist = CCur(NoNull(qryStats.ValueByName("AVGArtist"),0))
  592.  
  593.   ' process background threads
  594.   SDB.ProcessMessages
  595.  
  596.   strSQL = "SELECT Avg(CountOfID) AS AVGArtistPlayed FROM ("
  597.   strSQL = strSQL & "SELECT Count(ArtistsSongs.ID) AS CountOfID "
  598.   strSQL = strSQL & "FROM ArtistsSongs INNER JOIN Songs ON ArtistsSongs.IDSong = Songs.ID "
  599.   strSQL = strSQL & "INNER JOIN Played ON Songs.ID = Played.IDSong "
  600.   strSQL = strSQL & "WHERE (Songs.Artist <> '') AND (Songs.Artist NOTNULL) "
  601.   strSQL = strSQL & "GROUP BY ArtistsSongs.IDArtist)"
  602.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  603.   intSongsPerArtistPlayed = CCur(NoNull(qryStats.ValueByName("AVGArtistPlayed"),0))
  604.  
  605.   ' process background threads
  606.   SDB.ProcessMessages
  607.  
  608.   strSQL = "SELECT Avg(CountOfID) AS AVGYear FROM ("
  609.   strSQL = strSQL & "SELECT Count(Songs.ID) AS CountOfID "
  610.   'strSQL = strSQL & "FROM Songs "
  611.   strSQL = strSQL & "FROM Songs WHERE Songs.Year <> -1 "
  612.   strSQL = strSQL & "GROUP BY Songs.Year)"
  613.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  614.   intSongsPerYear = CCur(NoNull(qryStats.ValueByName("AVGYear"),0))
  615.  
  616.   ' process background threads
  617.   SDB.ProcessMessages
  618.  
  619.   strSQL = "SELECT Avg(CountOfID) AS AVGYearPlayed FROM ("
  620.   strSQL = strSQL & "SELECT Count(Songs.ID) AS CountOfID "
  621.   strSQL = strSQL & "FROM Songs INNER JOIN Played ON Songs.ID = Played.IDSong WHERE Songs.Year <> -1 "
  622.   strSQL = strSQL & "GROUP BY Songs.Year)"
  623.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  624.   intSongsPerYearPlayed = CCur(NoNull(qryStats.ValueByName("AVGYearPlayed"),0))
  625.  
  626.   'strSQL = "SELECT Avg(CountOfID) AS AVGTracksRating FROM ("
  627.   'strSQL = strSQL & "SELECT Count(Songs.ID) AS CountOfID "
  628.   'strSQL = strSQL & "FROM Songs WHERE Songs.Rating>0 "
  629.   'strSQL = strSQL & "GROUP BY Songs.Rating)"
  630.   'Set qryStats = SDB.Database.OpenSQL(strSQL)
  631.   'intSongsPerRating = CCur(NoNull(qryStats.ValueByName("AVGTracksRating"),0))
  632.  
  633.   'strSQL = "SELECT Avg(CountOfID) AS AVGTracksRatingPlayed FROM ("
  634.   'strSQL = strSQL & "SELECT Count(Songs.ID) AS CountOfID "
  635.   'strSQL = strSQL & "FROM Songs INNER JOIN Played ON Songs.ID = Played.IDSong WHERE Songs.Rating>0 "
  636.   'strSQL = strSQL & "GROUP BY Songs.Rating)"
  637.   'Set qryStats = SDB.Database.OpenSQL(strSQL)
  638.   'intSongsPerRatingPlayed = CCur(NoNull(qryStats.ValueByName("AVGTracksRatingPlayed"),0))
  639.  
  640.   ' process background threads
  641.   SDB.ProcessMessages
  642.  
  643.   strOut = strOut & "        <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf
  644.   strOut = strOut & "          <tr><th colspan=""3"">" & SDB.Localize("Averages") & "</th></tr>" & vbcrlf
  645.   strOut = strOut & "          <tr class=""aleft""><th>" & SDB.Localize("Type") & "</th><th>" & SDB.Localize("Library") & "</th><th>" & SDB.Localize("Played") & "</th></tr>" & vbcrlf
  646.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Tracks per Artist") & "</td><td>" & Round(intSongsPerArtist, 1) & "</td><td>" & Round(intSongsPerArtistPlayed, 1) & "</td></tr>" & vbcrlf
  647.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Tracks per Album") & "</td><td>" & Round(intTracksPerAlbum, 1) & "</td><td>" & Round(intTracksPerAlbumPlayed, 1) & "</td></tr>" & vbcrlf
  648.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Tracks per Genre") & "</td><td>" & Round(intSongsPerGenre, 1) & "</td><td>" & Round(intSongsPerGenrePlayed, 1) & "</td></tr>" & vbcrlf
  649.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Tracks per Year") & "</td><td>" & Round(intSongsPerYear, 1) & "</td><td>" & Round(intSongsPerYearPlayed, 1) & "</td></tr>" & vbcrlf
  650.   'strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Tracks per Rating") & "</td><td>" & Round(intSongsPerRating, 1) & "</td><td>" & Round(intSongsPerRatingPlayed, 1) & "</td></tr>" & vbcrlf
  651.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Bitrate (kbps)") & "</td><td>" & Round(intAvgBitrate/1000) & "</td><td>" & Round(intAvgBitratePlayed/1000) & "</td></tr>" & vbcrlf
  652.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Year") & "</td><td>" & Round(intAvgYear) & "</td><td>" & Round(intAvgYearPlayed) & "</td></tr>" & vbcrlf
  653.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Tracks played per day") & "</td><td>-</td><td>" & Round(intPlayPerDay, 1) & "</td></tr>" & vbcrlf
  654.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Rating") & "</td><td>" & ShowRating(Round(intAvgRating),booForExport) & "</td><td>" & ShowRating(Round(intPlayedRating),booForExport) & "</td></tr>" & vbcrlf
  655.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("Length") & " (h:mm:ss)</td><td>" & FormatTime(intLength) & "</td><td>" & FormatTime(intLengthPlayed) & "</td></tr>" & vbcrlf
  656.   strOut = strOut & "          <tr" & Style & "><td>" & SDB.Localize("File size") & "</td><td>" & FormatFileSize(intFileLength) & "</td><td>" & FormatFileSize(intFileLengthPlayed) & "</td></tr>" & vbcrlf
  657.   strOut = strOut & "        </table>" & vbcrlf
  658.   strOut = strOut & "      <p/>" & vbcrlf
  659.  
  660.   ' process background threads
  661.   SDB.ProcessMessages
  662.  
  663.   'Top 10 Artists
  664.   strOut = strOut & "        <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf
  665.   strOut = strOut & "          <tr><th colspan=""4"">" & SDB.Localize("Top " & intTopCount & " Artists") & "</th></tr>" & vbcrlf
  666.   strOut = strOut & "          <tr class=""aleft"">" & vbcrlf
  667.   strOut = strOut & "            <th>" & SDB.Localize("Tracks") & "</th>" & vbcrlf
  668.   strOut = strOut & "            <th>" & SDB.Localize("Artist") & "</th>" & vbcrlf
  669.   strOut = strOut & "            <th>" & SDB.Localize("Length") & "</th>" & vbcrlf
  670.   strOut = strOut & "            <th>" & SDB.Localize("File size") & "</th>" & vbcrlf
  671.   strOut = strOut & "          </tr>" & vbcrlf
  672.   strSQL = "SELECT Artists.ID, Artists.Artist, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Artists INNER JOIN ArtistsSongs ON Artists.ID = ArtistsSongs.IDArtist INNER JOIN Songs ON Songs.ID = ArtistsSongs.IDSong GROUP BY Artists.ID, Artists.Artist ORDER BY Count(Songs.ID) DESC LIMIT " & intTopCount & ""
  673.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  674.   While Not qryStats.EOF
  675.  
  676.   ' process background threads
  677.   SDB.ProcessMessages
  678.  
  679.   strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  680.   strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  681.   strOut = strOut & "            <td>" & MapXML(qryStats.StringByName("Artist")) & "</td>" & vbcrlf
  682.   strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  683.   strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  684.   strOut = strOut & "          </tr>" & vbcrlf
  685.     qryStats.Next
  686.   Wend
  687.   strOut = strOut & "        </table>" & vbcrlf
  688.   strOut = strOut & "      <p/>" & vbcrlf
  689.   
  690.   ' process background threads
  691.   SDB.ProcessMessages
  692.  
  693.   'Top 10 Artists Played
  694.   strOut = strOut & "        <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf
  695.   strOut = strOut & "          <tr><th colspan=""4"">" & SDB.Localize("Top " & intTopCount & " Artists played") & "</th></tr>" & vbcrlf
  696.   strOut = strOut & "          <tr class=""aleft"">" & vbcrlf
  697.   strOut = strOut & "            <th>" & SDB.Localize("Tracks") & "</th>" & vbcrlf
  698.   strOut = strOut & "            <th>" & SDB.Localize("Artist") & "</th>" & vbcrlf
  699.   strOut = strOut & "            <th>" & SDB.Localize("Length") & "</th>" & vbcrlf
  700.   strOut = strOut & "            <th>" & SDB.Localize("File size") & "</th>" & vbcrlf
  701.   strOut = strOut & "          </tr>" & vbcrlf
  702.   strSQL = "SELECT Artists.ID, Artists.Artist, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Artists INNER JOIN ArtistsSongs ON Artists.ID = ArtistsSongs.IDArtist INNER JOIN Songs ON Songs.ID = ArtistsSongs.IDSong INNER JOIN Played ON Songs.ID = Played.IdSong GROUP BY Artists.ID, Artists.Artist ORDER BY Count(Songs.ID) DESC LIMIT " & intTopCount & ""
  703.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  704.   While Not qryStats.EOF
  705.  
  706.   ' process background threads
  707.   SDB.ProcessMessages
  708.  
  709.   strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  710.   strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  711.   strOut = strOut & "            <td>" & MapXML(qryStats.StringByName("Artist")) & "</td>" & vbcrlf
  712.   strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  713.   strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  714.   strOut = strOut & "          </tr>" & vbcrlf
  715.     qryStats.Next
  716.   Wend
  717.   strOut = strOut & "        </table>" & vbcrlf
  718.   strOut = strOut & "      <p/>" & vbcrlf
  719.  
  720.   'Top 10 Albums
  721.   'strOut = strOut & "        <table border=""0"" cellspacing=""0"" cellpadding=""0"" width=""100%"">" & vbcrlf
  722.   'strOut = strOut & "          <tr><th colspan=""4"">" & SDB.Localize("Top") & " " & intTopCount & " " & SDB.Localize("Albums") & "</th></tr>" & vbcrlf
  723.   'strOut = strOut & "          <tr class=""aleft"">" & vbcrlf
  724.   'strOut = strOut & "            <th>" & SDB.Localize("Tracks") & "</th>" & vbcrlf
  725.   'strOut = strOut & "            <th>" & SDB.Localize("Album") & "</th>" & vbcrlf
  726.   'strOut = strOut & "            <th>" & SDB.Localize("Length") & "</th>" & vbcrlf
  727.   'strOut = strOut & "            <th>" & SDB.Localize("File size") & "</th>" & vbcrlf
  728.   'strOut = strOut & "          </tr>" & vbcrlf
  729.   'strSQL = "SELECT Albums.ID, Artists.Artist, Albums.Album, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Albums INNER JOIN ArtistsAlbums ON Albums.ID = ArtistsAlbums.IDAlbum INNER JOIN Artists ON Artists.ID = ArtistsAlbums.IDArtist INNER JOIN ArtistsSongs ON Artists.ID = ArtistsSongs.IDArtist INNER JOIN Songs ON Songs.ID = ArtistsSongs.IDSong ORDER BY Count(Songs.ID) DESC LIMIT " & intTopCount & ""
  730.   'Set qryStats = SDB.Database.OpenSQL(strSQL)
  731.   'While Not qryStats.EOF
  732.   'strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  733.   'strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  734.   'strOut = strOut & "            <td>" & MapXML(qryStats.StringByName("Artist")) & " - " & MapXML(qryStats.StringByName("Album")) & "</td>" & vbcrlf
  735.   'strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  736.   'strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  737.   'strOut = strOut & "          </tr>" & vbcrlf
  738.   '  qryStats.Next
  739.   'Wend
  740.   'strOut = strOut & "        </table>" & vbcrlf
  741.   'strOut = strOut & "      <p/>" & vbcrlf
  742.  
  743.   'Top 10 Albums played
  744.   strOut = strOut & "        <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf
  745.   strOut = strOut & "          <tr><th colspan=""4"">" & SDB.Localize("Top " & intTopCount & " Albums played") & "</th></tr>" & vbcrlf
  746.   strOut = strOut & "          <tr class=""aleft"">" & vbcrlf
  747.   strOut = strOut & "            <th>" & SDB.Localize("Tracks") & "</th>" & vbcrlf
  748.   strOut = strOut & "            <th>" & SDB.Localize("Album") & "</th>" & vbcrlf
  749.   strOut = strOut & "            <th>" & SDB.Localize("Length") & "</th>" & vbcrlf
  750.   strOut = strOut & "            <th>" & SDB.Localize("File size") & "</th>" & vbcrlf
  751.   strOut = strOut & "          </tr>" & vbcrlf
  752.   strSQL = "SELECT Albums.ID, Artists.ID AS ArID, Artists.Artist, Albums.Album, Count(Songs.ID) AS CountOfID, Sum(Songs.SongLength) AS TotalLength, Sum(Songs.FileLength) AS TotalFileLength FROM Albums INNER JOIN ArtistsAlbums ON Albums.ID = ArtistsAlbums.IDAlbum INNER JOIN Artists ON ArtistsAlbums.IDArtist = Artists.ID INNER JOIN ArtistsSongs ON ArtistsSongs.IDArtist = Artists.ID INNER JOIN Songs ON ArtistsSongs.IDSong = Songs.ID AND ArtistsAlbums.IDAlbum = Songs.IDAlbum INNER JOIN Played ON Songs.ID = Played.IDSong WHERE Albums.ID <> 0 Group By Albums.ID, Artists.ID, Artists.Artist, Albums.Album Order By Count(Songs.ID) Desc Limit " & intTopCount & ""
  753.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  754.   While Not qryStats.EOF
  755.  
  756.   ' process background threads
  757.   SDB.ProcessMessages
  758.  
  759.   strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  760.   strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  761.   strOut = strOut & "            <td>" & MapXML(qryStats.StringByName("Artist")) & " - " & MapXML(qryStats.StringByName("Album")) & "</td>" & vbcrlf
  762.   strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  763.   strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  764.   strOut = strOut & "          </tr>" & vbcrlf
  765.     qryStats.Next
  766.   Wend
  767.   strOut = strOut & "        </table>" & vbcrlf
  768.   strOut = strOut & "      <p/>" & vbcrlf
  769.   
  770.   ' process background threads
  771.   SDB.ProcessMessages
  772.  
  773.   'Top 10 Genres
  774.   strOut = strOut & "        <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf
  775.   strOut = strOut & "          <tr><th colspan=""4"">" & SDB.Localize("Top " & intTopCount & " Genres") & "</th></tr>" & vbcrlf
  776.   strOut = strOut & "          <tr class=""aleft"">" & vbcrlf
  777.   strOut = strOut & "            <th>" & SDB.Localize("Tracks") & "</th>" & vbcrlf
  778.   strOut = strOut & "            <th>" & SDB.Localize("Genre") & "</th>" & vbcrlf
  779.   strOut = strOut & "            <th>" & SDB.Localize("Length") & "</th>" & vbcrlf
  780.   strOut = strOut & "            <th>" & SDB.Localize("File size") & "</th>" & vbcrlf
  781.   strOut = strOut & "          </tr>" & vbcrlf
  782.   strSQL = "SELECT Genres.IDGenre, Genres.GenreName, Count(Songs.ID) AS CountOfID, Sum(Songs.SongLength) AS TotalLength, Sum(Songs.FileLength) AS TotalFileLength FROM Songs INNER JOIN GenresSongs ON Songs.ID = GenresSongs.IDSong INNER JOIN Genres ON Genres.IDGenre = GenresSongs.IDGenre Group By Genres.IDGenre, Genres.GenreName Order By Count(Songs.ID) Desc Limit " & intTopCount & ""
  783.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  784.   While Not qryStats.EOF
  785.  
  786.   ' process background threads
  787.   SDB.ProcessMessages
  788.  
  789.   strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  790.   strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  791.   strOut = strOut & "            <td>" & MapXML(qryStats.StringByName("GenreName")) & "</td>" & vbcrlf
  792.   strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  793.   strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  794.   strOut = strOut & "          </tr>" & vbcrlf
  795.     qryStats.Next
  796.   Wend
  797.   strOut = strOut & "        </table>" & vbcrlf
  798.   strOut = strOut & "      <p/>" & vbcrlf
  799.   
  800.   ' process background threads
  801.   SDB.ProcessMessages
  802.  
  803.   'Top 10 genres played
  804.   strOut = strOut & "        <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf
  805.   strOut = strOut & "          <tr><th colspan=""4"">" & SDB.Localize("Top " & intTopCount & " Genres played") & "</th></tr>" & vbcrlf
  806.   strOut = strOut & "          <tr class=""aleft"">" & vbcrlf
  807.   strOut = strOut & "            <th>" & SDB.Localize("Tracks") & "</th>" & vbcrlf
  808.   strOut = strOut & "            <th>" & SDB.Localize("Genre") & "</th>" & vbcrlf
  809.   strOut = strOut & "            <th>" & SDB.Localize("Length") & "</th>" & vbcrlf
  810.   strOut = strOut & "            <th>" & SDB.Localize("File size") & "</th>" & vbcrlf
  811.   strOut = strOut & "          </tr>" & vbcrlf
  812.   strSQL = "SELECT Genres.IDGenre, Genres.GenreName, Count(Songs.ID) AS CountOfID, Sum(Songs.SongLength) AS TotalLength, Sum(Songs.FileLength) AS TotalFileLength FROM Songs INNER JOIN Played ON Songs.ID = Played.IdSong INNER JOIN GenresSongs ON Songs.ID = GenresSongs.IDSong INNER JOIN Genres ON Genres.IDGenre = GenresSongs.IDGenre Group By Genres.IDGenre, Genres.GenreName Order By Count(Songs.ID) Desc Limit " & intTopCount & ""
  813.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  814.   While Not qryStats.EOF
  815.  
  816.   ' process background threads
  817.   SDB.ProcessMessages
  818.  
  819.   strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  820.   strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  821.   strOut = strOut & "            <td>" & MapXML(qryStats.StringByName("GenreName")) & "</td>" & vbcrlf
  822.   strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  823.   strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  824.   strOut = strOut & "          </tr>" & vbcrlf
  825.     qryStats.Next
  826.   Wend
  827.   strOut = strOut & "        </table>" & vbcrlf
  828.   strOut = strOut & "      <p/>" & VbCrLf
  829.  
  830.   ' process background threads
  831.   SDB.ProcessMessages
  832.  
  833.   'ratings
  834.   strOut = strOut & "        <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf
  835.   strOut = strOut & "          <tr><th colspan=""4"">" & SDB.Localize("Ratings") & "</th></tr>" & vbcrlf
  836.   strOut = strOut & "          <tr class=""aleft"">" & vbcrlf
  837.   strOut = strOut & "            <th>" & SDB.Localize("Tracks") & "</th>" & vbcrlf
  838.   strOut = strOut & "            <th>" & SDB.Localize("Rating") & "</th>" & vbcrlf
  839.   strOut = strOut & "            <th>" & SDB.Localize("Length") & "</th>" & vbcrlf
  840.   strOut = strOut & "            <th>" & SDB.Localize("File size") & "</th>" & vbcrlf
  841.   strOut = strOut & "          </tr>" & vbcrlf
  842.  
  843.   '91 - 100 ratings
  844.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 91) AND (Songs.Rating <= 100)"
  845.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  846.  
  847.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  848.     While Not qryStats.EOF
  849.  
  850.       ' process background threads
  851.       SDB.ProcessMessages
  852.  
  853.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  854.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  855.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  856.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  857.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  858.       strOut = strOut & "          </tr>" & vbcrlf
  859.       qryStats.Next
  860.     Wend
  861.   End If
  862.  
  863.   '81 - 90 ratings
  864.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 81) AND (Songs.Rating <= 90)"
  865.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  866.  
  867.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  868.     While Not qryStats.EOF
  869.  
  870.       ' process background threads
  871.       SDB.ProcessMessages
  872.  
  873.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  874.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  875.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  876.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  877.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  878.       strOut = strOut & "          </tr>" & vbcrlf
  879.       qryStats.Next
  880.     Wend
  881.   End If
  882.  
  883.   '71 - 80 ratings
  884.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 71) AND (Songs.Rating <= 80)"
  885.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  886.  
  887.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  888.     While Not qryStats.EOF
  889.  
  890.       ' process background threads
  891.       SDB.ProcessMessages
  892.  
  893.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  894.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  895.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  896.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  897.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  898.       strOut = strOut & "          </tr>" & vbcrlf
  899.       qryStats.Next
  900.     Wend
  901.   End If
  902.  
  903.   '61 - 70 ratings
  904.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 61) AND (Songs.Rating <= 70)"
  905.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  906.  
  907.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  908.     While Not qryStats.EOF
  909.  
  910.       ' process background threads
  911.       SDB.ProcessMessages
  912.  
  913.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  914.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  915.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  916.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  917.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  918.       strOut = strOut & "          </tr>" & vbcrlf
  919.       qryStats.Next
  920.     Wend
  921.   End If
  922.  
  923.   '51 - 60 ratings
  924.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 51) AND (Songs.Rating <= 60)"
  925.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  926.  
  927.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  928.     While Not qryStats.EOF
  929.  
  930.       ' process background threads
  931.       SDB.ProcessMessages
  932.  
  933.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  934.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  935.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  936.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  937.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  938.       strOut = strOut & "          </tr>" & vbcrlf
  939.       qryStats.Next
  940.     Wend
  941.   End If
  942.  
  943.   '41 - 50 ratings
  944.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 41) AND (Songs.Rating <= 50)"
  945.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  946.  
  947.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  948.     While Not qryStats.EOF
  949.  
  950.       ' process background threads
  951.       SDB.ProcessMessages
  952.  
  953.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  954.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  955.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  956.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  957.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  958.       strOut = strOut & "          </tr>" & vbcrlf
  959.       qryStats.Next
  960.     Wend
  961.   End If
  962.  
  963.   '31 - 40 ratings
  964.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 31) AND (Songs.Rating <= 40)"
  965.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  966.  
  967.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  968.     While Not qryStats.EOF
  969.  
  970.       ' process background threads
  971.       SDB.ProcessMessages
  972.  
  973.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  974.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  975.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  976.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  977.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  978.       strOut = strOut & "          </tr>" & vbcrlf
  979.       qryStats.Next
  980.     Wend
  981.   End If
  982.  
  983.   '21 - 30 ratings
  984.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 21) AND (Songs.Rating <= 30)"
  985.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  986.  
  987.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  988.     While Not qryStats.EOF
  989.  
  990.       ' process background threads
  991.       SDB.ProcessMessages
  992.  
  993.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  994.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  995.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  996.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  997.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  998.       strOut = strOut & "          </tr>" & vbcrlf
  999.       qryStats.Next
  1000.     Wend
  1001.   End If
  1002.  
  1003.   '11 - 20 ratings
  1004.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 11) AND (Songs.Rating <= 20)"
  1005.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1006.  
  1007.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1008.     While Not qryStats.EOF
  1009.  
  1010.       ' process background threads
  1011.       SDB.ProcessMessages
  1012.  
  1013.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1014.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1015.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1016.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1017.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1018.       strOut = strOut & "          </tr>" & vbcrlf
  1019.       qryStats.Next
  1020.     Wend
  1021.   End If
  1022.  
  1023.   '1 - 10 ratings
  1024.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE (Songs.Rating >= 1) AND (Songs.Rating <= 10)"
  1025.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1026.  
  1027.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1028.     While Not qryStats.EOF
  1029.  
  1030.       ' process background threads
  1031.       SDB.ProcessMessages
  1032.  
  1033.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1034.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1035.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1036.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1037.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1038.       strOut = strOut & "          </tr>" & vbcrlf
  1039.       qryStats.Next
  1040.     Wend
  1041.   End If
  1042.  
  1043.   '0 ratings
  1044.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs WHERE Songs.Rating = 0"
  1045.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1046.  
  1047.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1048.     While Not qryStats.EOF
  1049.  
  1050.       ' process background threads
  1051.       SDB.ProcessMessages
  1052.  
  1053.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1054.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1055.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1056.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1057.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1058.       strOut = strOut & "          </tr>" & vbcrlf
  1059.       qryStats.Next
  1060.     Wend
  1061.   End If
  1062.  
  1063.   strOut = strOut & "        </table>" & vbcrlf
  1064.   strOut = strOut & "      <p/>" & vbcrlf
  1065.  
  1066.   'rating played
  1067.   strOut = strOut & "        <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf
  1068.   strOut = strOut & "          <tr><th colspan=""4"">" & SDB.Localize("Ratings played") & "</th></tr>" & vbcrlf
  1069.   strOut = strOut & "          <tr class=""aleft"">" & vbcrlf
  1070.   strOut = strOut & "            <th>" & SDB.Localize("Tracks") & "</th>" & vbcrlf
  1071.   strOut = strOut & "            <th>" & SDB.Localize("Rating") & "</th>" & vbcrlf
  1072.   strOut = strOut & "            <th>" & SDB.Localize("Length") & "</th>" & vbcrlf
  1073.   strOut = strOut & "            <th>" & SDB.Localize("File size") & "</th>" & vbcrlf
  1074.   strOut = strOut & "          </tr>" & vbcrlf
  1075.  
  1076.   '91 - 100 ratings played
  1077.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs INNER JOIN Played ON Songs.ID = Played.IdSong WHERE (Songs.Rating >= 91) AND (Songs.Rating <= 100)"
  1078.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1079.  
  1080.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1081.     While Not qryStats.EOF
  1082.  
  1083.       ' process background threads
  1084.       SDB.ProcessMessages
  1085.  
  1086.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1087.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1088.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1089.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1090.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1091.       strOut = strOut & "          </tr>" & vbcrlf
  1092.       qryStats.Next
  1093.     Wend
  1094.   End If
  1095.  
  1096.   '81 - 90 ratings played
  1097.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs INNER JOIN Played ON Songs.ID = Played.IdSong WHERE (Songs.Rating >= 81) AND (Songs.Rating <= 90)"
  1098.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1099.  
  1100.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1101.     While Not qryStats.EOF
  1102.  
  1103.       ' process background threads
  1104.       SDB.ProcessMessages
  1105.  
  1106.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1107.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1108.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1109.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1110.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1111.       strOut = strOut & "          </tr>" & vbcrlf
  1112.       qryStats.Next
  1113.     Wend
  1114.   End If
  1115.  
  1116.   '71 - 80 ratings played
  1117.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs INNER JOIN Played ON Songs.ID = Played.IdSong WHERE (Songs.Rating >= 71) AND (Songs.Rating <= 80)"
  1118.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1119.  
  1120.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1121.     While Not qryStats.EOF
  1122.  
  1123.       ' process background threads
  1124.       SDB.ProcessMessages
  1125.  
  1126.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1127.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1128.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1129.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1130.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1131.       strOut = strOut & "          </tr>" & vbcrlf
  1132.       qryStats.Next
  1133.     Wend
  1134.   End If
  1135.  
  1136.   '61 - 70 ratings played
  1137.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs INNER JOIN Played ON Songs.ID = Played.IdSong WHERE (Songs.Rating >= 61) AND (Songs.Rating <= 70)"
  1138.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1139.  
  1140.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1141.     While Not qryStats.EOF
  1142.  
  1143.       ' process background threads
  1144.       SDB.ProcessMessages
  1145.  
  1146.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1147.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1148.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1149.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1150.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1151.       strOut = strOut & "          </tr>" & vbcrlf
  1152.       qryStats.Next
  1153.     Wend
  1154.   End If
  1155.  
  1156.   '51 - 60 ratings played
  1157.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs INNER JOIN Played ON Songs.ID = Played.IdSong WHERE (Songs.Rating >= 51) AND (Songs.Rating <= 60)"
  1158.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1159.  
  1160.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1161.     While Not qryStats.EOF
  1162.  
  1163.       ' process background threads
  1164.       SDB.ProcessMessages
  1165.  
  1166.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1167.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1168.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1169.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1170.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1171.       strOut = strOut & "          </tr>" & vbcrlf
  1172.       qryStats.Next
  1173.     Wend
  1174.   End If
  1175.  
  1176.   '41 - 50 ratings played
  1177.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs INNER JOIN Played ON Songs.ID = Played.IdSong WHERE (Songs.Rating >= 41) AND (Songs.Rating <= 50)"
  1178.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1179.  
  1180.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1181.     While Not qryStats.EOF
  1182.  
  1183.       ' process background threads
  1184.       SDB.ProcessMessages
  1185.  
  1186.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1187.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1188.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1189.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1190.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1191.       strOut = strOut & "          </tr>" & vbcrlf
  1192.       qryStats.Next
  1193.     Wend
  1194.   End If
  1195.  
  1196.   '31 - 40 ratings played
  1197.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs INNER JOIN Played ON Songs.ID = Played.IdSong WHERE (Songs.Rating >= 31) AND (Songs.Rating <= 40)"
  1198.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1199.  
  1200.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1201.     While Not qryStats.EOF
  1202.  
  1203.       ' process background threads
  1204.       SDB.ProcessMessages
  1205.  
  1206.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1207.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1208.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1209.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1210.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1211.       strOut = strOut & "          </tr>" & vbcrlf
  1212.       qryStats.Next
  1213.     Wend
  1214.   End If
  1215.  
  1216.   '21 - 30 ratings played
  1217.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs INNER JOIN Played ON Songs.ID = Played.IdSong WHERE (Songs.Rating >= 21) AND (Songs.Rating <= 30)"
  1218.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1219.  
  1220.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1221.     While Not qryStats.EOF
  1222.  
  1223.       ' process background threads
  1224.       SDB.ProcessMessages
  1225.  
  1226.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1227.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1228.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1229.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1230.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1231.       strOut = strOut & "          </tr>" & vbcrlf
  1232.       qryStats.Next
  1233.     Wend
  1234.   End If
  1235.  
  1236.   '11 - 20 ratings played
  1237.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs INNER JOIN Played ON Songs.ID = Played.IdSong WHERE (Songs.Rating >= 11) AND (Songs.Rating <= 20)"
  1238.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1239.  
  1240.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1241.     While Not qryStats.EOF
  1242.  
  1243.       ' process background threads
  1244.       SDB.ProcessMessages
  1245.  
  1246.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1247.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1248.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1249.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1250.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1251.       strOut = strOut & "          </tr>" & vbcrlf
  1252.       qryStats.Next
  1253.     Wend
  1254.   End If
  1255.  
  1256.   '1 - 10 ratings played
  1257.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs INNER JOIN Played ON Songs.ID = Played.IdSong WHERE (Songs.Rating >= 1) AND (Songs.Rating <= 10)"
  1258.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1259.  
  1260.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1261.     While Not qryStats.EOF
  1262.  
  1263.       ' process background threads
  1264.       SDB.ProcessMessages
  1265.  
  1266.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1267.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1268.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1269.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1270.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1271.       strOut = strOut & "          </tr>" & vbcrlf
  1272.       qryStats.Next
  1273.     Wend
  1274.   End If
  1275.  
  1276.   '0 ratings played
  1277.   strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength FROM Songs INNER JOIN Played ON Songs.ID = Played.IdSong WHERE Songs.Rating = 0"
  1278.   Set qryStats = SDB.Database.OpenSQL(strSQL)
  1279.  
  1280.   If CLng(qryStats.StringByName("CountOfID")) > 0 Then
  1281.     While Not qryStats.EOF
  1282.  
  1283.       ' process background threads
  1284.       SDB.ProcessMessages
  1285.  
  1286.       strOut = strOut & "          <tr" & Style() & ">" & vbcrlf
  1287.       strOut = strOut & "            <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf
  1288.       strOut = strOut & "            <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf
  1289.       strOut = strOut & "            <td>" & FormatTime(CCur(NoNull(qryStats.ValueByName("TotalLength"), 0))) & "</td>" & vbcrlf
  1290.       strOut = strOut & "            <td>" & FormatFileSize(CCur(NoNull(qryStats.ValueByName("TotalFileLength"), 0))) & "</td>" & vbcrlf
  1291.       strOut = strOut & "          </tr>" & vbcrlf
  1292.       qryStats.Next
  1293.     Wend
  1294.   End If
  1295.  
  1296.   strOut = strOut & "        </table>" & vbcrlf
  1297.   strOut = strOut & "      <p/>" & vbcrlf
  1298.  
  1299.   strOut = strOut & "      <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf
  1300.   strOut = strOut & "        <tr><td style='border-bottom-width:0px'>" & vbcrlf
  1301.   strOut = strOut & "          " & SDB.Localize("Generated by ") & "<a href='http://www.mediamonkey.com'>MediaMonkey</a>" & SDB.Localize(" ON ") & MapXML(FormatDateTime(date(), vbLongDate)) & " " & SDB.Localize("at") & " " & MapXml(FormatDateTime(time(), vbLongTime))
  1302.   strOut = strOut & "        </td></tr>" & vbcrlf
  1303.   strOut = strOut & "      </table>" & vbcrlf
  1304.   strOut = strOut & "    <p/>" & vbcrlf
  1305.  
  1306.   strOut = strOut & "  </body>" & vbcrlf
  1307.   strOut = strOut & "</html>" & vbcrlf
  1308.  
  1309.  
  1310.   ' process background threads
  1311.   SDB.ProcessMessages
  1312.  
  1313.   BuildReport = strOut
  1314. End Function
  1315.  
  1316.